<?php
session_start();
require_once '../header.php';
function __autoload($className)
	{
    	require_once('../class/' . $className . '.class.php');
	}
session::need_member();
$UserId=session::getuserid();
$post=$_POST;
$lr_paidto=rtrim(trim($_post["lr_paidto"]));
$lr_paidby=rtrim(trim($post["lr_paidby"]));
$lr_store="freshstorenew";
$lr_amnt=rtrim(trim($post["lr_amnt"]));
$lr_transfer=rtrim(trim($post["lr_transfer"]));
$lr_currency=rtrim(trim($post["lr_currency"]));
$secret_word="csa*&^$#32vDG";
$hashPost=rtrim(trim($post["lr_encrypted"]));
$hashword="U6593813:$lr_paidby:$lr_store:$lr_amnt:$lr_transfer:$lr_currency:$secret_word";
$hash=hash("SHA256", $hashword);
$Uper=strtoupper($hash);
$token_respond=rtrim(trim($post["token"]));
$token=$_SESSION["token"];
if(($Uper==$hashPost)&&($token_respond==$token))
{
	$checkBatch=user::checkpermission("lrverifier","verifier=$lr_transfer", "lrid is not null");
	if($checkBatch=='0')
	{
		unset($_SESSION["token"]);
		$lrAmount=intval($lr_amnt);
		$balancePlus=abs($lrAmount);
		$batch=intval($lr_transfer);
		$insertBatch=database::Insert("lrverifier", array(
		'verifier' => $batch
		));
	 	$Date=date("Y-m-d");
		if($balancePlus>=100)
		{
			$AmountAfterPlus=(ceil($balancePlus/20)+$balancePlus);
		}
		else 
		{
			$AmountAfterPlus=$balancePlus;
		}
		$plusNewYear=$AmountAfterPlus/10;
		$plusNewYear=round($plusNewYear,1);
		$AmountAfterPlus=$AmountAfterPlus+$plusNewYear;
		database::Insert('payment', array('userid' => $UserId,'date' => $Date,'amount' => $AmountAfterPlus,'reason' => "DEPOSIT $balancePlus FROM LR Account: $lr_paidby : $batch ",'lr' => $balancePlus));
		database::Update('userinfo',array('userid' => $UserId),array('money' => array( "money + {$AmountAfterPlus}"),'deposit' => array("deposit + {$balancePlus}")));
		$_SESSION["erro"]="Successful ! Your Balance has been Added";
		redirect::location("../membercp.php");
		
	}
	else
	{
	
		$_SESSION["erro"]="Problem with your payment, make sure you have made the payment,plz create new ticket and our staff will solve this problem";
		redirect::location("../membercp.php");
		
	}
}
else 
{
	$_SESSION["erro"]="Problem with your payment, make sure you have made the payment";
	redirect::location("../membercp.php");
}

?>